package priv.winnine.util;

import priv.winnine.entity.Result;
import priv.winnine.entity.enums.ResultEnum;

public class ResultUtil {

    public static Result success() {
        return result(ResultEnum.SUCCESS);
    }

    public static Result fail() {
        return result(ResultEnum.FAIL);
    }

    public static <T> Result<T> success(T data) {
        return result(ResultEnum.SUCCESS, data);
    }

    public static <T> Result<T> fail(T data) {
        return result(ResultEnum.FAIL, data);
    }

    public static Result result(ResultEnum resultEnum) {
        return Result.builder().code(resultEnum.getCode()).message(resultEnum.getMessage()).build();
    }

    public static <T> Result<T> result(ResultEnum resultEnum, T data) {
        return result(resultEnum.getCode(), resultEnum.getMessage(), data);
    }

    public static <T> Result<T> result(Integer code, String message, T data) {
        return (Result<T>) Result.builder().code(code).message(message).data(data).build();
    }
}
